<?php

class Country_Widget_AllPhotosController extends Engine_Content_Widget_Abstract
{
  public function indexAction()
  {
    // Don't render this if not authorized
    $viewer = Engine_Api::_()->user()->getViewer();
    $this->view->subject = $subject = Engine_Api::_()->core()->getSubject();
   
    if(!$subject->getIdentity()) {
      return $this->setNoRender();
    }
    $request = Zend_Controller_Front::getInstance()->getRequest();
    $page = $request->getParam('page');
    
    $photoTable = Engine_Api::_()->getDbtable("photos","country");
    $select = $photoTable->getSellectAllPhotoOfCountry($subject->country_id);
    
    $paginator  = Zend_Paginator::factory($select);
    $paginator->setItemCountPerPage(20);
    $paginator->setCurrentPageNumber($page);
  
    $this->view->country = $subject;
    $this->view->paginator = $paginator;
  }
}